package util;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import com.alibaba.druid.pool.DruidDataSource;

public class DBUtils {
	private static DataSource datasource;
	
	static {
		String driver= "com.mysql.cj.jdbc.Driver";
		String url="jdbc:mysql://localhost:3306/scott_db?serverTimezone=GMT%2B8";
		String username = "root";
		String password = "123456";
		
		DruidDataSource dds = new DruidDataSource();
		dds.setDriverClassName(driver);	
		dds.setUrl(url);
		dds.setUsername(username);
		dds.setPassword(password);
		dds.setInitialSize(10);
		dds.setMinIdle(10);
		dds.setMaxActive(30);
		
		datasource = dds;
	}
	
	public static Connection getConnection() throws SQLException {
		return datasource.getConnection();
	}
}
